<template>
  <div class="container">
    <div class="top-box">
      <div class="left-box">
        <div class="color-box"></div>
        <p>设备详情</p>
      </div>
      <div class="right-box">
        <el-button type="info" icon="el-icon-back" class="btn_fanhui" @click="Return">返回</el-button>
      </div>
    </div>
    <div class="content-box">
      <div class="title-box">基本信息</div>
      <div class="header-box">
        <el-form :inline="true" class="demo-form-inline" label-width="100px">
          <el-form-item label="设备编号">
            <el-input :disabled="true" v-model="item.equipmentNumber"></el-input>
          </el-form-item>
          <el-form-item label="设备名称">
            <el-input :disabled="true" v-model="item.name"></el-input>
          </el-form-item>
          <el-form-item label="设备地址">
            <el-input :disabled="true" v-model="item.address"></el-input>
          </el-form-item>
          <el-form-item label="购买时间">
            <el-input :disabled="true" v-model="item.buyTime"></el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="Content-By">
      <el-table :data="tableData" :max-height="400">
        <el-table-column prop="date" label="序号" type="index" align="center" width="100"></el-table-column>
        <el-table-column prop="createOnStr" label="申请时间" align="center"></el-table-column>
        <el-table-column prop="badDate" label="故障时间" align="center"></el-table-column>
        <el-table-column prop="repairDate" label="维修时间" align="center"></el-table-column>
        <el-table-column prop="creater" label="申请人" align="center"></el-table-column>
        <el-table-column prop="state" label="状态" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              size="small"
              type="warning"
              @click="shenhe(scope.row.id,scope.row.type,0)"
              v-if="shows==0&&scope.row.paixu==1"
            >审核</el-button>
            <el-button
              size="small"
              type="warning"
              @click="shenhe(scope.row.id,scope.row.type,0)"
              v-if="shows==0&&scope.row.paixu==2"
            >确认</el-button>
            <el-button size="small" type="primary" @click="shenhe(scope.row.id,scope.row.type,1)">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <template>
      <el-pagination
        style="text-align: center;"
        background
        layout="prev, pager, next"
        :current-page="current"
        :page-size="pagesize"
        @current-change="handleCurrentChange"
        :total="total"
      ></el-pagination>
    </template>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data () {
    return {
      total: 1,
      current: 1,
      pagesize: 10,
      item: { equipmentNumber: "", name: "", address: "", buyTime: "" },
      tableData: [],
      id: 0,
      shows: 1,
    };
  },
  created () {
    this.id = this.$route.query.e;
    this.shows = this.$route.query.shows;
    this.getlist(0);
  },
  methods: {
    // 分页
    handleCurrentChange (e) {
      this.getlist(e - 1);
    },
    getlist (page) {
      let obj = {
        id: this.id,
        pn: page,
        PerPageSize: this.pagesize
      };
      var objs = JSON.stringify(obj);
      let the = { index: 10, jsondata: objs }
      console.log(objs);
      axios.post("/apis/AdministrationManage.asmx/GetData", the).then(({ data }) => {
        var list = eval('(' + data.d + ')');
        console.log(list);
        this.item = list.item;
        this.total = list.count;
        this.tableData = list.data;
      });
    },
    shenhe (e, type, shows) {
      this.$router.push({
        path: "./Routinemaintenancetwoxiangq",
        query: { e: e, type: type, shows: shows }
      });
    },
    Return () {
      window.history.go(-1);
    },
  }
};
</script>
<style lang="scss" scoped>
@import '@/assets/scss/base.scss';
.top-box {
  width: 100%;
  height: 60px;
  overflow: hidden;
  // border: 1px solid $red;
}
.left-box {
  width: 100px;
  height: 40px;
  float: left;
  margin-top: 10px;
  overflow: hidden;
  margin-left: 1%;
  // border: 1px solid red;
}
.color-box {
  width: 5px;
  height: 20px;
  float: left;
  margin-top: 10px;
  background-color: $Header_color;
}
.left-box p {
  float: left;
  margin-left: 5px;
  line-height: 40px;
}
.right-box {
  float: right;
  width: 90px;
  height: 40px;
  margin-right: 2%;
  border-radius: 8px;
  margin-top: 10px;
  background-color: $return-color;
  // border: 1px solid red;
}
.right-box:hover {
  background-color: #a4a6ad;
}

.right-box img {
  width: 30px;
  height: 30px;
  margin-top: 5px;
  margin-left: 6px;
  float: left;
  // border: 1px solid red;
}
.content-box {
  width: 98%;
  margin: 0 auto;
  border-radius: 2px;
  background-color: $white;
}
.title-box {
  width: 96%;
  height: 60px;
  margin: 0 auto;
  line-height: 60px;
  border-bottom: 1px solid $bordercolor;
}
.header-box {
  margin-top: 20px;
}
.Content-By {
  margin: 0 auto;
  margin-left: 15px;
  margin-top: 15px;
  border-radius: 2px;
  background-color: white;
  width: 98%;
  text-align: center;
}
</style>
